package java3_8;

import java.util.Arrays;
import java.util.Scanner;

/**
 * 6：一项体育赛事，7名裁判打分，分数范围是[0-10],
 * 选手最后的得分是去掉一个最高分和一个最低分，剩下的分数和。
 * 请输入分数，计算某选手最后的得分（分数要控制范围）
 */
public class homework6 {
    public static void main(String[] args) {
        double [] a = new double[7];//存储7名裁判打分的数组
        double [] b = new double[5];//存储去掉最高分和最低分后的数组
        double sum = 0;
        double temp = 0;
        Scanner scanner = new Scanner(System.in);
        for (int i = 0; i < 7;) {
            System.out.println("请第"+(i+1)+"名裁判打分:");
            a[i] = scanner.nextDouble();
            if (a[i]>10||a[i]<0){
                System.out.println("输入错误！请重新输入：");
                continue;
            }
            i++;
            for (int j = 0; j < a.length-1; j++) {
                for (int k = 0; k < a.length-1; k++) {
                    if (a[k+1]>a[k]){
                        temp = a[k+1];
                        a[k+1] = a[k];
                        a[k] = temp;
                    }
                }
            }
        }
        System.out.println(Arrays.toString(a));
        for (int i = 0; i < b.length; i++) {
            b[i] = a[i+1];
            sum = sum + b[i];
        }
        System.out.println(Arrays.toString(b));
        System.out.println("选手最后的得分为："+sum);
    }
}
